<?php
class StatisticsSeasonTeam extends AppModel {

	var $name = 'StatisticsSeasonTeam';
	var $primaryKey = 'ID';

	var $belongsTo = array(
		'Team' => array(
			'className' => 'Team',
			'foreignKey' => 'idTeam_Listing',
			'fields' => array('Team.ID', 'Team.strName'),
	));

	function __construct($id = false, $table = null, $ds = null) {
		parent::__construct($id, $table, $ds);
		$this->virtualFields = array(
			'iMatch' => sprintf('(%s.iWins+%s.iDraws+%s.iLoss)', $this->alias, $this->alias, $this->alias),
			'fPerWins'  => sprintf('100*(%s.iWins / CAST((%s.iWins+%s.iDraws+%s.iLoss) AS REAL))', $this->alias, $this->alias, $this->alias, $this->alias),
			'fPerDraws' => sprintf('100*(%s.iDraws / CAST((%s.iWins+%s.iDraws+%s.iLoss) AS REAL))', $this->alias, $this->alias, $this->alias, $this->alias),
    	'fPerLoss'  => sprintf('100*(%s.iLoss / CAST((%s.iWins+%s.iDraws+%s.iLoss) AS REAL))', $this->alias, $this->alias, $this->alias, $this->alias)
		);
	}
}
?>